/**************************************************************************
 * @doc PRINT
 * @module print.h |  
 * Header file for handling the printer functionality
 *
 * Product     :   SoftPay 2000 (Global Payment Methodology).
 * <nl>Developer   :   
 * <nl>Notes       :
 *
 * @head3 Printer Functions |
 * @index | Print
 * @end
 *
 * Copyright (c) 1996-2000 by VeriFone Inc. All rights reserved.
 * 
 * No part of this software may be used, stored, compiled, reproduced,
 * modified, transcribed, translated, transmitted, or transferred, in any form 
 * or by any means whether electronic, mechanical, magnetic, optical, 
 * or otherwise, without the express prior written permission of VeriFone, Inc.
 *
 * Revision History
 * ------------------------------------------------------------------------
 $Log: /SoftPay/SPK2SIM/Source/Include/print.h $
 ********************************************************************************/
#ifndef VSPRINT_H
#define VSPRINT_H

#include <formater.h>
#include <define.h>
#include <transact.h>

#define BL_LINE            1            /* Print blank lines in receipt   */
#define NO_BL_LINE         0            /* No blank lines in receipt      */
typedef int (*IFP)();

/*
 * The error codes, returned by the routines in "receipt printing" module.
 * When the function fails, the relevent error code is copied to "errno"
 * global variable, which could be referred to, by the calling functions.
 */

#define E_NOT_OPENED         (-1000)  /* RS232 port is NOT opened */
#define E_SET_BAUD_ERR       (-1001)  /* Setting of baud rate is failed */
#define E_NO_TEMPLATE_FL     (-1002)  /* The template file doesn't exist */
#define E_INVALID_PRINTER    (-1003)  /* Printer type is invalid */
#define E_NOT_INITED         (-1004)  /* Printer/formatter not initialised */
#define E_INVALID_LINES      (-1005)  /* From line > To line */
#define E_NO_PRINTER         (-1006)  /* Requested printer is not connected */

#define QUICK_PRINTER_TIME_OUT      1   /* In 1/2 seconds */
#define PRINTER_TIME_OUT            6   /* In 1/2 seconds */

/*
 * The "Receipt printing module" supports all types of VeriFone printers.
 * In particular, following printers are supported. These definitions are
 * to be used, while refering to these printers.
 */
/* Printer Types - The values of printer types must match the occurences of the printer
    in the inInitFns[] array. The printers for which there are not entries must be last */

#define NOPRINTER		0                       /* When no printer or printer other than those below  */
#define PRINTER_DEFAULT	0                    /* Default printer (When no printer driver available) */

typedef struct TagPRINTER_PROPERTIES
{
	int		inColumnType;
	VS_BOOL	fThermal;
} PRINTER_PROPERTIES;

extern PRINTER_PROPERTIES	srPtrProps[];

/*
 *      Column Mode Values
 */
#define COLUMN_TYPE_24     		0
#define COLUMN_TYPE_32     		1
#define COLUMN_TYPE_42     		2
#define COLUMN_TYPE_MULTIPLE	3

typedef struct printer_struct
{
	int inHandle;
	int inType;

	int (*inSelCharSet)(void *);
	short (*shInit)(short, short);
	short (*shPrint)(void *, char *);
	short (*shStatus)(short, short);
	short (*shClose)(short);
	unsigned char *(*inMode)(unsigned char, unsigned char *);
	void (*vdFormFeed)(void *);

} PRINTER_OBJECT;

extern PRINTER_OBJECT obPrinter;
extern unsigned long lnHeaderCondition;
extern unsigned long lnMiddleCondition;
extern unsigned long lnBottomCondition;

extern short (*shInitFns[])(short, short);
extern short (*shPrintFns[])(short, unsigned char *);
extern short (*shStatusFns[])(short, short);
extern short (*shCloseFns[])(short);
extern unsigned char *(*inModeFns[])(unsigned char, unsigned char *);
extern short (*shIdFns[])(short, short);
extern short (*shDnldGraphicFns[])(short, short);


int	inInitPrintandForm (TRANSACTION_OBJECT *pobTran);
short default_init (short hPrinter, short inTimeout);
short default_print (short hPrinter, unsigned char *pchTemp);
short default_close (short hPrinter);
void vdFormFeed (PRINTER_OBJECT *obPrinter);
short shSpool(PRINTER_OBJECT *obPrinter, char *szBuffer);
int inSelCharSetFn(PRINTER_OBJECT *obPrinter);
void vdInitializePrinter(PRINTER_OBJECT *obPrinter);
int inSetupForm(FORMATER *psrFormater, int);
void vdGetPrinterName(char *szPathName, int inComIndex);
int inOpenPrinter(void);
int inChkPrinterStatus (PRINTER_OBJECT *pobPrinter);
int inPrintLines(PRINTER_OBJECT *obPrinter, int inFromLine, int inToLine, int inBlLine, unsigned long lnCondition);
int inOpenFormater(char *szFormName, PRINTER_OBJECT *obPrinter);
int inCloseFormater (void);
int inSwitchTemplate (char *szTemplateName);
void p350ColumnMode (int mode);
void p350LinesPerInch (int lpi);
int	inPrintFormFeedsOperation(TRANSACTION_OBJECT *pobTran);

#ifdef PRINTISO_DEFINED
int inPrintISOPacket(VS_BOOL fSendPacket, unsigned char *pucMessage, int inLen); //jrd 01052004
#endif /* PRINTISO_DEFINED */


#endif /* VSPRINT_H */
